package com.crane.api.task;

import com.crane.oss.api.constants.SynchronousRedisQueue;
import com.crane.oss.school.syn.SynXunfeiService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


/**
 * @author zx
 */
@Component
public class DataSynchronousTask {

    @Resource
    SynXunfeiService synXunfeiService;

    @Scheduled(fixedDelay = 1 * 60 * 1000)
    public void processArea() {
        synXunfeiService.sysData(SynchronousRedisQueue.AREA_QUEUE_ADD);
        synXunfeiService.sysData(SynchronousRedisQueue.AREA_QUEUE_UPDATE);
        synXunfeiService.sysData(SynchronousRedisQueue.AREA_QUEUE_DELETE);
    }

    @Scheduled(fixedDelay = 1 * 60 * 1000)
    public void processClass() {
        synXunfeiService.sysData(SynchronousRedisQueue.CLASS_QUEUE_ADD);
        synXunfeiService.sysData(SynchronousRedisQueue.CLASS_QUEUE_UPDATE);
        synXunfeiService.sysData(SynchronousRedisQueue.CLASS_QUEUE_DELETE);
    }

    @Scheduled(fixedDelay = 1 * 60 * 1000)
    public void processStudent() {
        synXunfeiService.sysData(SynchronousRedisQueue.STUDENT_QUEUE_ADD);
        synXunfeiService.sysData(SynchronousRedisQueue.STUDENT_QUEUE_UPDATE);
        synXunfeiService.sysData(SynchronousRedisQueue.STUDENT_QUEUE_DELETE);
    }

    @Scheduled(fixedDelay = 1 * 60 * 1000)
    public void processTeacher() {
        synXunfeiService.sysData(SynchronousRedisQueue.TEACHER_QUEUE_ADD);
        synXunfeiService.sysData(SynchronousRedisQueue.TEACHER_QUEUE_UPDATE);
        synXunfeiService.sysData(SynchronousRedisQueue.TEACHER_QUEUE_DELETE);
    }

    @Scheduled(fixedDelay = 1 * 60 * 1000)
    public void processRefClass() {
        synXunfeiService.sysData(SynchronousRedisQueue.REF_CLASS_QUEUE_ADD);
        synXunfeiService.sysData(SynchronousRedisQueue.REF_CLASS_QUEUE_UPDATE);
        synXunfeiService.sysData(SynchronousRedisQueue.TEACHER_QUEUE_DELETE);
    }

    @Scheduled(fixedDelay = 1 * 60 * 1000)
    public void processTeachCycle() {
        synXunfeiService.sysData(SynchronousRedisQueue.TEACHCYCLE_QUEUE_ADD);
        synXunfeiService.sysData(SynchronousRedisQueue.TEACHCYCLE_QUEUE_UPDATE);
        synXunfeiService.sysData(SynchronousRedisQueue.TEACHCYCLE_QUEUE_DELETE);
    }

}
